//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    motto: 'Hello World!',
    userInfo1: {
      nickName: 'MyTest!!! '
    },
    userInfo: {},
    systemInfo:{},
    location:{}
  },

  onShow:function(){
    var that = this;
    //获取用户资料
    wx.getUserInfo({
      success: function(res){
        // success
        that.setData({
          userInfo:res.userInfo
        });
      },
      fail: function() {
        // fail
      },
      complete: function() {
        // complete
      }
    });

    //获取系统信息
    wx.getSystemInfo({
      success: function(res) {
        // success
        that.setData({
          systemInfo:res
        });
      }
    });

    //获取位置信息
    wx.getLocation({
      type: 'wgs84', // 默认为 wgs84 返回 gps 坐标，gcj02 返回可用于 wx.openLocation 的坐标
      success: function(res){
        // success
        that.setData({
          location:res
        })
      },
      fail: function() {
        // fail
      },
      complete: function() {
        // complete
      }
    });
  },

  onLoad: function () {
    console.log('onLoad')
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
  },


  //事件处理函数
  //点击头像
  bindUserImgTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },

  //跳转至：通知功能
  gotoInformTap: function() {
    wx.navigateTo({
      url: '../inform/inform'
    })
  },

  //跳转至：每日家庭作业
  gotoHomeWorkTap: function() {
    wx.navigateTo({
      url: '../homework/homework'
    })
  },

  //跳转至：报名/统计
  gotoEnrollTap: function() {
    wx.navigateTo({
      url: '../enroll/enroll'
    })
  }
})
